<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="../template/layout.xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	<ui:param name="pageHeaderTitle" value="Treatment requests" />
	<ui:define name="content">	
		<br />
		<h2 style="text-align: center">Treatment requests</h2>			
		<div id="inner_content">
		<h:panelGrid columns="2" style="width: 600px">
		<h:column>
			<p:outputLabel value="Period start "/>
			<br />		
			<h:form>
				<p:calendar value="#{viewDoctorTreatmentRequestListBean.startDate}" converter="stringToCalendarConverterNoTime" 
									id="startDate" showOn="button" styleClass="pCalendar" readonly="#{facesContext.renderResponse}" pattern="MM/dd/yyyy">
					<p:ajax event="dateSelect" listener="#{viewDoctorTreatmentRequestListBean.dateChange}" update=":resultTable" />				
				</p:calendar>
			</h:form>
		</h:column>
		<h:column>
			<p:outputLabel value="Period end "/>
			<br />		
			<h:form>
				<p:calendar value="#{viewDoctorTreatmentRequestListBean.endDate}" converter="stringToCalendarConverterNoTime" 
									id="endDate" showOn="button" styleClass="pCalendar" readonly="#{facesContext.renderResponse}" pattern="MM/dd/yyyy">
					<p:ajax event="dateSelect" listener="#{viewDoctorTreatmentRequestListBean.dateChange}" update=":resultTable" />				
				</p:calendar>
			</h:form>
		</h:column>
		</h:panelGrid>
		<br /><br />
		<h:panelGroup id="resultTable">
		<p:dataTable style="width: 700px" id="treatmentRequestsResultTable" var="treatmentRequest" value="#{viewDoctorTreatmentRequestListBean.requestList}" paginator="true" rows="10"  paginatorAlwaysVisible="false" 
		                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}" paginatorPosition="bottom" pageLinks="5" selectionMode="single" rowKey="#{treatmentRequest.id}">
			<p:ajax event="rowSelect" listener="#{viewDoctorTreatmentRequestListBean.onRowSelect}" />
			
			<p:column headerText="Client" style="width: 50%">
				<h:outputText value="#{treatmentRequest.act.client.firstName} #{treatmentRequest.act.client.lastName}" />
			</p:column>
			
			<p:column headerText="Meet time" style="width: 25%">
				<h:outputText value="#{treatmentRequest.meetDate}" converter="stringToCalendarConverterWithTime" />
			</p:column>
			
			<p:column headerText="Accepted" style="width: 25%">
				<h:outputText style="color: green" value="Yes" rendered="#{treatmentRequest.acceptStatus}" />
				<h:outputText style="color: red" value="No" rendered="#{not treatmentRequest.acceptStatus}" />
			</p:column>
			
		</p:dataTable>				
		</h:panelGroup>
		</div>	
		<br /><br />
		<div id="treatment_list_info" >
			<p:messages />
		</div>	
	</ui:define>
</ui:composition>
</html>